/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * 
 */

var loginApp = angular.module("loginApp", []);


loginApp.controller("loginController", function ($scope, $http) {

   

    $scope.loginData = {};

    $scope.processFormLogin = function () {

        $http({
            method: 'POST',
            url: 'Authenticate.do',
            data: $.param($scope.loginData),
            headers: {'Content-Type': 'application/x-www-form-urlencoded'}
        }).success(function () {

            window.setTimeout(function () {
                $(location).attr('href', "Home.do");
            }, 100);
        }).error(function () {
            dataUnLoading();
            $(".msg").html('<p class="alert alert-danger"><strong>Login ou Senha Inválidos</strong></p>').fadeIn('fast'),
                    setTimeout(function () {
                        $(".msg").hide();
                    }, 1000);
        });


    };
    function dataLoading() {
        $("#loading").css({display: "block"}).delay(1000);
    }
    function dataUnLoading() {
        $("#loading").css({display: "none"});
    }


});

